package org.jeecg.modules.cxf;

import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.jeecg.modules.integration.service.DataService;
import org.jeecg.modules.integration.service.impl.DataServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

/**
 * @Description Cxf 发布所有接口到服务
 * @Author linminfeng
 * @Date 2020-11-07 15:34
 */
@Configuration
public class CxfConfig {

    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus(){
        System.out.println("进来了");
        return new SpringBus();
    }

    @Bean
    public DataService dataService(){
        return  new DataServiceImpl();
    }

    @Bean
    public Endpoint endpoint(){
        EndpointImpl endpoint = new EndpointImpl(springBus(), dataService());
        endpoint.publish("/integration");
        //endpoint.getInInterceptors().add(new WsInterceptor());
        System.out.println("WebService Server is OK ...");
        return endpoint;
    }

}
